{extend name="./app/system/view_mobile/public/layout.html" /}
{block name="title"}往来单位对冲管理{/block}
{block name="head"}{/block}
{block name="body"}
<div class="ibox">
    <div class="ibox-content">
        <table class="table table-bordered">
            <thead>
            <tr>
                <th>单位名称</th>
                <th>行程单详情</th>
                <th>订单总计</th>
                <th>定金总计</th>
                <th>已付款总计</th>
                <th>折扣金额总计</th>
                <th>待收款总计</th>
            </tr>
            </thead>
            <tbody>
            {volist name="list" id="vo"}
            <tr>
                <td>{$vo.btypeinfo2.company}-{$vo.btypeinfo2.title}({$vo.btypeinfo2.btype_phone})</td>
                <td>
                    <table class="table table-no-bordered">
                        <tr>
                            <th>车辆</th>
                            <th>订单金额</th>
                            <th>已付定金</th>
                            <th>已付款</th>
                            <th>折扣金额</th>
                        </tr>
                        {volist name="vo.item2" id="vo2"}
                        <tr>
                            <td>{$vo2.car_sn}</td>
                            <td>{$vo2.order_charge}</td>
                            <td>{$vo2.order_advance}</td>
                            <td>{$vo2.order_pay}</td>
                            <td>{$vo2.discount_money}</td>
                        </tr>
                        {/volist}
                    </table>
                </td>
                <td>{$vo.right.sum_order_charge}</td>
                <td>{$vo.right.sum_order_advance}</td>
                <td>{$vo.right.sum_order_pay}</td>
                <td>{$vo.right.sum_discount_money}</td>
                <td>{$vo.order_q2}</td>
            </tr>
            <tr>
                <td>{$vo.btypeinfo1.company}-{$vo.btypeinfo1.title}({$vo.btypeinfo1.btype_phone})</td>
                <td>
                    <table class="table table-no-bordered">
                        <tr>
                            <th>车辆</th>
                            <th>订单金额</th>
                            <th>已付定金</th>
                            <th>已付款</th>
                            <th>折扣金额</th>
                        </tr>
                        {volist name="vo.item1" id="vo1"}
                        <tr>
                            <td>{$vo1.car_sn}</td>
                            <td>{$vo1.order_charge}</td>
                            <td>{$vo1.order_advance}</td>
                            <td>{$vo1.order_pay}</td>
                            <td>{$vo1.discount_money}</td>
                        </tr>
                        {/volist}
                    </table>
                </td>
                <td>{$vo.sum_order_charge}</td>
                <td>{$vo.sum_order_advance}</td>
                <td>{$vo.sum_order_pay}</td>
                <td>{$vo.sum_discount_money}</td>
                <td>{$vo.order_q1}</td>
            </tr>
            <tr class="success">
                <td colspan="6" class="text-right">
                    {if ($vo.order_q2-$vo.order_q1)>0}
                    需收取对方
                    <span class="text-danger" style="font-size:24px;">{$vo.order_q2-$vo.order_q1}</span>元
                    {else/}
                    需支付对方
                    <span class="text-danger" style="font-size:24px;">{$vo.order_q1-$vo.order_q2}</span>元
                    {/if}
                </td>
                <td><a href="javascript:;" class="btn btn-info btn-block" onclick="hedge('{$vo.btype_aid}');">对冲</a></td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </div>
</div>
{/block}
{block name="script"}
<script>
    function hedge(btype_aid) {
        In('layer',function () {
            layer.confirm('对冲后会自动冲抵双方行程单<br/>' +
                '<strong class="text-danger">对冲金额大于0需对方单位付本方单位金额</strong><br/>' +
                '<strong class="text-danger">对冲金额小于0为本方单位需付对方单位金额</strong><br/>' +
                '确认完成对冲吗?', {icon: 3, title:'提示'}, function(index){
                getAjax('/system/logic.order/hedge.html',{btype_aid:btype_aid},function (res) {
                    if(res.code==1){
                        rePage();
                    }else{
                        alert(res.msg);
                    }
                });
                layer.close(index);
            });
        })
        /*
        top.layer.confirm('对冲后会自动冲抵双方行程单<br/>' +
            '<strong class="text-danger">对冲金额大于0需对方单位付本方单位金额</strong><br/>' +
            '<strong class="text-danger">对冲金额小于0为本方单位需付对方单位金额</strong><br/>' +
            '确认操作吗?', {icon: 3, title:'提示'}, function(index){

            top.layer.close(index);
        });
        */
    }
</script>
{/block}